@extends("layouts.app",['categories'=>get_categoires_all()])

@section('title',$topic->category->name.' - '.$topic->title)
@section('desc',$topic->desc)



@section('content')


    <div class="row">
        {{--帖子内容--}}
        <div class="col-md-9">
            <div class="card">

                <div class="card-body text-center">
                    <h5 class="card-title text-dark-emphasis"><b>{{$topic->title}}</b></h5>

                    <small>
                        <i class="fa-regular fa-user"></i>
                        <a class="text-decoration-none text-secondary" href="{{route('users.show',$topic->user->id)}}">
                            {{$topic->user->name}}
                        </a>
                        &nbsp;|&nbsp;
                        <i class="fa-solid fa-list"></i>
                        <a class="text-decoration-none " href="{{route('categories.show',$topic->category->id)}}">
                            {{$topic->category->name}}
                        </a>
                        &nbsp;|&nbsp;
                        <i class="fa-regular fa-comment-dots"></i>
                        <span class="text-decoration-none text-secondary" href="#">
                            {{$topic->reply_count}}
                        </span>
                        &nbsp;|&nbsp;
                        <i class="fa-regular fa-clock"></i>
                        <span class="text-decoration-none text-secondary" href="#}">
                            {{$topic->created_at->diffForHumans()}}
                        </span>
                    </small>

                    <div class="text-center mt-2 d-flex justify-content-center">
                        <button class="btn btn-sm btn-outline-secondary border-0">
                            <a class="text-decoration-none text-secondary-emphasis" href="{{route('topics.create')}}">
                                <i class="fa-solid fa-circle-plus"></i> 发帖
                            </a>
                        </button>
                        @can('update',$topic)
                            <button class="btn btn-sm btn-outline-info border-0">
                                <a class="text-decoration-none text-secondary-emphasis" href="{{route('topics.edit',$topic->id)}}">
                                    <i class="fa-solid fa-pen-to-square"></i> 编辑
                                </a>
                            </button>

                            <form action="{{route('topics.destroy',$topic->id)}}" method="post" onsubmit="return confirm('是否删除帖子？')">
                                @csrf
                                @method('DELETE')
                                <button class="btn btn-sm btn-outline-danger border-0 text-decoration-none text-secondary-emphasis" type="submit">
                                        <i class="fa-solid fa-eraser"></i> 删除
                                </button>
                            </form>

                        @endif

                    </div>

                </div>
                {{--帖子内容--}}
                <div class="card-body">
                    <p class="card-text">{!! $topic->content !!}</p>
                </div>

                {{--发表评论--}}
                @if(Auth::id())
                    @include('topics._address_reply')
                @endif
            </div>



            {{--评论列表--}}
            <div class="card mt-4">
                <div class="card-body border-0 px-3 py-2 ">评论</div>

                @include('topics._reply_list',[
                                    'replies'=>$topic->replies()->with('user')->recent()->get(),
                                    $topic,
                                    'count'=>$topic->replies()->count()])
            </div>
        </div>

        {{--帖主相关--}}
        <div class="col-md-3 d-none d-md-block">
            <div class="card">
                <div class="card-header ">帖主：<a class="text-decoration-none text-secondary-emphasis"
                   href="{{route('users.show',$topic->user->id)}}">{{$topic->user->name}}</a></div>
                <div class="card-group">
                    {{--帖主头像--}}
                    <div class="card border-0 w50">
                        <img  src="{{$topic->user->avatar}}" class="card-img-top img-thumbnail border-0" alt="头像">
                    </div>
                    {{--自定义信息--}}
                    <div class="card border-0 mt-4">
                        <div class="card border-0" >
                            <ul class="list-group list-group-flush">
                                <li class="list-group-item"><i class="fa-regular fa-envelope"></i> 发帖数</li>
                                <li class="list-group-item"><i class="fa-regular fa-thumbs-up"></i> 获赞数</li>
                                <li class="list-group-item"><i class="fa-brands fa-gratipay"></i> 特别关注</li>
                            </ul>
                        </div>
                    </div>
                </div>
                {{--个人简介--}}
                <div class="card-body">
                    <h5 class="card-title">个人简介</h5>
                    <p class="card-text">{{$topic->user->info}}</p>
                </div>
                <div class="card-footer">
                    <small class="text-muted">最近活跃： {{$topic->user->updated_at->diffForHumans()}}</small>
                </div>
            </div>
        </div>

    </div>

@stop


